using System.Data.Entity.ModelConfiguration;
using Turquoise.Entities.Data;

namespace Turquoise.DataAccess.EntityFramework.Mappings
{

    public class SettingMapping : EntityTypeConfiguration<Setting>
    {

        public SettingMapping(string schema = "dbo")
        {
            ToTable(schema + ".Setting");
            HasKey(x => x.Id);

            Property(x => x.Id).HasColumnName("Id").IsRequired().HasColumnType("int").HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);
            Property(x => x.SettingKey).HasColumnName("SettingKey").IsRequired().HasColumnType("nvarchar").HasMaxLength(100);
            Property(x => x.SettingValue).HasColumnName("SettingValue").IsRequired().HasColumnType("nvarchar").HasMaxLength(500);
            Property(x => x.CreateDate).HasColumnName("CreateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.CreatedBy).HasColumnName("CreatedBy").IsRequired().HasColumnType("int");
            Property(x => x.UpdateDate).HasColumnName("UpdateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.UpdatedBy).HasColumnName("UpdatedBy").IsRequired().HasColumnType("int");

            HasRequired(a => a.User_CreatedBy).WithMany(b => b.Settings_CreatedBy).HasForeignKey(c => c.CreatedBy);
            HasRequired(a => a.User_UpdatedBy).WithMany(b => b.Settings_UpdatedBy).HasForeignKey(c => c.UpdatedBy);
        }
    }

}

